package code.android.util;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import android.content.Context;
import android.graphics.Bitmap;

public class FileCore extends Object 
{
	
	public static void saveBitmapToFile(Context context, Bitmap bitmap, String fileName)
	{
		try {
			FileOutputStream fos = context.openFileOutput(fileName, Context.MODE_PRIVATE);
			
			bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);
			
			fos.close();
			
		} catch (FileNotFoundException e) 
		{
			e.printStackTrace();
		} catch (IOException e) 
		{
			e.printStackTrace();
		}
	}

	public FileCore() 
	{
		super();
	}
	
	public PrivateStorage getPrivateStorageInstance( Context context )
	{
		PrivateStorage ps = new PrivateStorage(context);
		
		return ps;
	}
	
	public PublicStorage getPublicStorageInstance()
	{
		PublicStorage ps = new PublicStorage();
		
		return ps;
	}

	public class PrivateStorage
	{
		Context mContext = null;
		
		public PrivateStorage(Context context) 
		{
			mContext = context;
		}
		
		public String getFullPath()
		{
			return null;
		}
		
		public String[] fileList()
		{
			String[] a = null;
			
			a = mContext.fileList();
			
			return a;
		}
		
		public void makeDirectory(String name)
		{
			mContext.getDir(name, Context.MODE_PRIVATE);
		}
		
		
		
		public void createFile(String name)
		{
			try {
				FileOutputStream fos = mContext.openFileOutput(name, Context.MODE_PRIVATE);
				fos.close();
	
				
			} catch (FileNotFoundException e) 
			{
				e.printStackTrace();
			} catch (IOException e) 
			{
				e.printStackTrace();
			}
		}
	}
	
	public class PublicStorage
	{
		public PublicStorage() 
		{
			// TODO Auto-generated constructor stub
		}
		
	}
	
	
}
